package com.pervasive.container;

import java.util.HashMap;
import java.util.Map;

import com.pervasive.project.unified.data.constants.Constants;

public class GameContainer {

	private static GameContainer gameContainer;
	
	private Map<String, Map<Constants.cardId, ContainerStruc>> userDataMap; 
	
	private GameContainer()
	{
		userDataMap = new HashMap<String, Map<Constants.cardId, ContainerStruc>>();
	}
	
	public static GameContainer getGameContainerInstance()
	{
		if(gameContainer != null)
			return gameContainer;
		
		gameContainer = new GameContainer();
		return gameContainer;
	}
	
	public void insertData(String userName, Constants.cardId cardId, int score, String pixName)
	{
		if(!userDataMap.containsKey(userName))
			userDataMap.put(userName, new HashMap<Constants.cardId, ContainerStruc>());
		
		userDataMap.get(userName).put(cardId, new ContainerStruc(pixName, score));
	}
	
	public void deleteData(String userName, Constants.cardId cardId)
	{
		if(userDataMap.containsKey(userName))
			if(userDataMap.get(userName).containsKey(cardId))
				userDataMap.get(userName).remove(cardId);
	}
	
	public void cleanContainer()
	{
		if(userDataMap != null)
			userDataMap.clear();
	}
	
	public Map<String, Map<Constants.cardId, ContainerStruc>> getUserData()
	{
		return userDataMap;
	}
	
}
